<?php

namespace app\api\service;

trait GetFlowSum
{
    /**
     * 获取应付金额
     * @param $data
     * @return bool|mixed
     */
    public static function getTotal($data)
    {
        if ($data['supplierReconciliation']) {
            return $data['supplierReconciliation']['amount'];
        }
        if ($data['purchaseReturn']) {
            return $data['purchaseReturn']['payment'];
        }
        if ($data['purchase']) {
            return $data['purchase']['total'];
        }
        return 0;
    }

    /**
     * 获取实付金额
     */
    public static function getPayment($data)
    {
        if ($data['supplierReconciliation']) {
            return $data['supplierReconciliation']['amount'];
        }
        if ($data['purchaseReturn']) {
            return $data['purchaseReturn']['payment'];
        }
        if ($data['purchase']) {
            return $data['purchase']['payment'];
        }
        return 0;
    }
}
